<?php 
include('../../../../inc/application_settings.php');

$email = $_COOKIE['EMAIL'];
$password = Cryptic::decrypt($_COOKIE['PASSWORD'], $email);
$auth = new Authentication($email, $password);

if ($auth->checkAuthentication())
	$output = loadGrid();
else 
	$output = 'Not authenticated!';
echo $output;


function loadGrid(){
	$output = '<div class="outputtable" style="margin-top: -10px; margin-left: -10px; width:100% "><table style="width:100%">';
	$output .= '<tr><th style="width: 30px"></th><th style="width: 200px">Erstellungsdatum</th><th style="width: 200px">Headline</th><th style="width: 200px">Kurzinfo</th><th>Anzeigedauer</th></tr>';
	$sql = 'select NEWS_ID, CREATIONDATE, HEADLINE_DE, SHORT_INFO_DE, DISPLAY_FROM, DISPLAY_TO from ' . DB_BIO . '.news_view order by creationdate, headline_de'; 
	$sqlObj = Sql_Object::getInstance();
	$sqlObj->connect();
	$sqlObj->execute($sql);
	while(($row = $sqlObj->fetch()) != null){
		$output .= '<tr>';
		$output .= '<td><img onclick="handleEdit(' . $row['NEWS_ID'] . ');" src="' . ADMIN_IMAGES . '/edit.png" style="width: 16px; height: 16px; cursor: pointer; border: none" alt="edit.png" /></td>';
		$output .= '<td >' . $row['CREATIONDATE'] . '</td>';
		$output .= '<td>' . $row['HEADLINE_DE'] . '</td>';
		$output .= '<td>' . $row['SHORT_INFO_DE'] . '</td>';
		$output .= '<td>' . $row['DISPLAY_FROM'] . ' - ' . $row['DISPLAY_TO'] . '</td>';
		$output .= '</tr>';
	}
	$output .= '</div>';
	$sqlObj->disconnect();
	return $output;
}



?>